import { Injectable } from '@nestjs/common';
import { CreateOtaDto } from './dto/create-ota.dto';
import { UpdateOtaDto } from './dto/update-ota.dto';

@Injectable()
export class OtaService {
  private cur_relevance_id = 0;
  private hostList = [
    {
      ap_version: '025_5_5_v1.1.12',
      cp_version: 'XIAOBAI_highrail_svn0710_v1_v1.img',
      host_version: '025_5_1_v1.1.15',
      id: 0,
    },
    {
      ap_version: '025_5_5_v1.1.13',
      cp_version: 'XIAOBAI_highrail_svn0605_v1.img',
      host_version: '025_5_1_v1.1.15',
      id: 1,
    },
    {
      ap_version: '025_5_5_v1.1.14',
      cp_version: 'XIAOBAI_highrail_svn0710_v1_v1.',
      host_version: '025_5_1_v1.1.12',
      id: 2,
    },
    {
      ap_version: '025_5_5_v1.1.15',
      cp_version: 'XIAOBAI_highrail_svn0710_v1_v1.',
      host_version: '025_5_1_v1.1.12',
      id: 3,
    },
    {
      ap_version: '025_5_5_v1.1.16',
      cp_version: 'XIAOBAI_highrail_svn0710_v1_v1.',
      host_version: '025_5_1_v1.1.12',
      id: 4,
    },
    {
      ap_version: '025_5_5_v1.1.12',
      cp_version: 'XIAOBAI_highrail_svn0710_v1_v1.',
      host_version: '025_5_1_v1.1.12',
      id: 5,
    },
    {
      ap_version: '025_5_5_v1.1.12',
      cp_version: 'XIAOBAI_highrail_svn0710_v1_v1.',
      host_version: '025_5_1_v1.1.15',
      id: 6,
    },
    {
      ap_version: '025_5_5_v1.1.12',
      cp_version: 'XIAOBAI_highrail_svn0710_v1_v1.',
      host_version: '025_5_1_v1.1.12',
      id: 7,
    },
    {
      ap_version: '025_5_5_v1.1.12',
      cp_version: 'XIAOBAI_highrail_svn0710_v1_v1.',
      host_version: '025_5_1_v1.1.12',
      id: 8,
    },
  ];

  getHostList() {
    return {
      code: 200,
      data:{
        relevance:this.hostList,
        cur_relevance_id:this.cur_relevance_id,
      },
    };
  }

  switchHost(id: number) {
    this.cur_relevance_id = id;
    return {
      code: 200,
      data:this.cur_relevance_id,
    };
  }

  deleteHost(id: number) {
    this.hostList = this.hostList.filter((item) => item.id !== id);
    return {
      code: 200,
      data:this.hostList,
    };
  }
}
